package cn.wd.user.service.impl;


import cn.wd.common.util.StrUtils;
import cn.wd.common.vo.R;
import cn.wd.user.domain.entity.ConfigInfo;
import cn.wd.user.domain.mapper.ConfigInfoMapper;
import cn.wd.user.page.PageResult;
import cn.wd.user.qo.ConfigInfoQueryObject;
import cn.wd.user.qo.QueryObject;
import cn.wd.user.service.IConfigInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConfigInfoServiceImpl extends ServiceImpl<ConfigInfoMapper, ConfigInfo> implements IConfigInfoService {

    private final ConfigInfoMapper mapper;

    public ConfigInfoServiceImpl(ConfigInfoMapper mapper) {
        this.mapper = mapper;
    }

    // @Override
    // public List<ConfigInfo> selectAll() {
    //     return mapper.selectAll();
    // }
    //
    // @Override
    // public void save(ConfigInfo obj) {
    //     mapper.insert(obj);
    // }
    //
    // @Override
    // public void updateById(ConfigInfo obj) {
    //     mapper.updateByPrimaryKey(obj);
    // }
    //
    // @Override
    // public ConfigInfo selectById(Long id) {
    //     return mapper.selectByPrimaryKey(id);
    // }

    @Override
    public Page<ConfigInfo> listConfigInfoPage(ConfigInfoQueryObject qo) {
        LambdaQueryWrapper<ConfigInfo> wrapper = new LambdaQueryWrapper<ConfigInfo>()
                .like(StrUtils.hasText(qo.getKeyword()), ConfigInfo::getProp, qo.getKeyword());
        return baseMapper.selectCustomPage(qo, wrapper);
    }

    // @Override
    // public void deleteById(Long id) {
    //     mapper.deleteByPrimaryKey(id);
    // }

    @Override
    public ConfigInfo selectByKey(String key) {
        return mapper.selectByKey(key);
    }

    @Override
    public void batchDelete(Long[] deletedIds) {
        mapper.batchDelete(deletedIds);
    }
}
